package com.fdq.dianping.service.impl;

import cn.hutool.core.util.RandomUtil;
import com.fdq.dianping.entity.User;
import com.fdq.dianping.mapper.UserMapper;
import com.fdq.dianping.service.UserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fdq.dianping.util.Constants;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author fdq
 * @since 2024-12-29
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
    //按手机号新增用户
    public User insertUserByPhone(String phone){
        //1.创建用户
        User user = new User();
        user.setPhone(phone);
        user.setNickName(Constants.User_NickName_Prefix+ RandomUtil.randomString(Constants.User_NickName_Num));
        //默认密码123456
        user.setPassword("123456");
        //2.保存用户
        save(user);
        return user;
    }
}
